﻿// 7-1 电话聊天狂人 (25 分).cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<stack>
#include <algorithm>
using namespace std;

class B
{
public:
	long long s;
	long long c;
	B* p;
	B()
	{
		s = 0;
		c = 0;
		p = NULL;
	}
	B(long long s1)
	{
		s = s1;
		c = 1;
		p = NULL;
	}

};
bool cmp(long long x, long long y) {
	return x > y;
}
//先对长整形数组排序，再遍历数组将内容放入结构体
int main()
{
	long long c;

	long   i, c1,  d;
	int c2 = 0;
	long k = 0;
	long j = 0;
	long n;

	cin >> n;
	long long* a1 = new long long[2 * n];


	for (i = 0; i < 2 * n; i++)
	{
		cin >> c;
		a1[i] = c;
	}
	i--;
	sort(a1, a1 + n + n,cmp);//11 11 22 33 44 44

	B* head = new B(a1[i]);//这些定义一定不要放在循环里面！！
	B* b1 = new B(a1[i]);


		for (; i > 0; i--)//因为下面比较用的是i-1，所以i > 0
		{
			if (j == 0)
			{
				b1 = head;
				j++;
				i++;
			}
			else {
				if (a1[i] != a1[i - 1])
				{
					b1->p = new B(a1[i - 1]);
					if (k == 0) { k++; head->p = b1->p; }

					b1 = b1->p;

				}
				else
				{

					(b1->c)++;
					 
				}
			}
		}
	//}
	//遍历指针一次，找到最大结构体。
	B* p1 = new B();
	B* p2 = new B();
	p1 = head;
	p2 = p1;
	while(p1!=NULL){
		if (p1->p != NULL&&p1->c < (p1->p->c))//这里一定要多判断一个p1->p != NULL
		{
			p2 = p1->p;
		}
		
		p1 = p1->p;
	}
	p1 = head;
	while (p1 != NULL)
	{
	
		if ( p2->c == p1->c)//这里一定要多判断一个p1->p != NULL
		{
			c2++;
		}

		p1 = p1->p;
	}

		if (c2 == 1)
		{
			cout << p2->s << " " << p2->c;
		}
		else
		{
			cout << p2->s << " " << p2->c << " " << c2;
		}

}